package com.nl.lib_project.view.dialog

import android.app.Activity
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.gzuliyujiang.dialog.ModalDialog
import com.nl.lib_core.tool.extends.dp2px
import com.nl.lib_project.R
import com.nl.lib_project.adapter.AlzheimerLookBackParentAdapter
import com.nl.lib_project.entity.AlzheimerKeyValue
import com.nl.lib_project.entity.AlzheimerLookBackAnswersEntity

/** 作者:LiBW 创建日期:2022/6/28 描述:阿尔兹海默症 回看记录dialog */
class AlzheimerLookBackDialog(
    activity: Activity,
) : ModalDialog(activity) {
  init {
    setWidth(context.dp2px(320f))
    setHeight(context.dp2px(220f))
  }
  override fun createBodyView(): View {
    val view = View.inflate(context, R.layout.dialog_alzheimer_look_back, null)
    val recyclerView: RecyclerView = view.findViewById(R.id.mRecyclerView)
    val params =
        ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
    recyclerView.layoutParams = params

    val adapter = AlzheimerLookBackParentAdapter()
    recyclerView.adapter = adapter
    recyclerView.layoutManager = LinearLayoutManager(activity)
    val data = ArrayList<AlzheimerLookBackAnswersEntity>()

    val bean1 = AlzheimerLookBackAnswersEntity()
    bean1.time = "2022-5-5"
    val hashMap1 = ArrayList<AlzheimerKeyValue>()
    hashMap1.add(AlzheimerKeyValue("花", false))
    hashMap1.add(AlzheimerKeyValue("花", true))
    hashMap1.add(AlzheimerKeyValue("花", false))
    hashMap1.add(AlzheimerKeyValue("花", true))
    hashMap1.add(AlzheimerKeyValue("花", false))
    bean1.answers = hashMap1
    data.add(bean1)

    val bean2 = AlzheimerLookBackAnswersEntity()
    bean2.time = "2022-5-5"
    val hashMap2 = ArrayList<AlzheimerKeyValue>()
    hashMap2.add(AlzheimerKeyValue("勺子", false))
    hashMap2.add(AlzheimerKeyValue("勺子", true))
    hashMap2.add(AlzheimerKeyValue("勺子", true))
    hashMap2.add(AlzheimerKeyValue("勺子", true))
    hashMap2.add(AlzheimerKeyValue("勺子", true))
    hashMap2.add(AlzheimerKeyValue("勺子", true))
    bean2.answers = hashMap2
    data.add(bean2)
    adapter.setNewInstance(data)
    return view
  }

  override fun createHeaderView(): View? {
    val view = View.inflate(activity, R.layout.dialog_header_style_5, null)
    view.findViewById<TextView>(R.id.dialog_modal_title).text = "回看记录"
    return view
  }

  override fun onCancel() {}

  override fun onOk() {}

  override fun createFooterView(): View? {
    return null
  }
}
